
let dataList = [
    {
        "姓名": "李支山",
        "OA账号": "lizhishan",
        "联系电话": "18602030197"
    },
    {
        "姓名": "余佩玲",
        "OA账号": "yupeiling",
        "联系电话": "18602031828"
    },
    {
        "姓名": "杨晨",
        "OA账号": "yangchen23",
        "联系电话": "18620011859"
    },
    {
        "姓名": "李勇军",
        "OA账号": "liyj286",
        "联系电话": "18602030955"
    },
    {
        "姓名": "陈丹群",
        "OA账号": "chendq32",
        "联系电话": "18602032015"
    },
    {
        "姓名": "周洪波",
        "OA账号": "zhouhb22",
        "联系电话": "18602034569"
    },
    {
        "姓名": "陈洋",
        "OA账号": "cheny1034",
        "联系电话": "18620018287"
    },
    {
        "姓名": "范荣辉",
        "OA账号": "fanronghui",
        "联系电话": "18602030278"
    },
    {
        "姓名": "陈国豪",
        "OA账号": "chengh83",
        "联系电话": "18602030560"
    },
    {
        "姓名": "丁先诚",
        "OA账号": "dingxc",
        "联系电话": "18602031545"
    },
    {
        "姓名": "何小利",
        "OA账号": "hexl67",
        "联系电话": "18602032998"
    },
    {
        "姓名": "汪亮",
        "OA账号": "liangwang",
        "联系电话": "18602030078"
    },
    {
        "姓名": "邹志锋",
        "OA账号": "zouzf3",
        "联系电话": "18620012322"
    },
    {
        "姓名": "周艳",
        "OA账号": "zhouy81",
        "联系电话": "18602031195"
    },
    {
        "姓名": "郑泽彬",
        "OA账号": "zhengzb21",
        "联系电话": "18620010447"
    },
    {
        "姓名": "王薇",
        "OA账号": "wangwei816",
        "联系电话": "18602030537"
    },
    {
        "姓名": "冯永雄",
        "OA账号": "fengyx",
        "联系电话": "18602031881"
    },
    {
        "姓名": "赵江",
        "OA账号": "zhaojiang9",
        "联系电话": "18620011482"
    },
    {
        "姓名": "王宇翔",
        "OA账号": "wangyx2458",
        "联系电话": "18620010521"
    },
    {
        "姓名": "司徒智敏",
        "OA账号": "gd-sitzm",
        "联系电话": "18620012248"
    },
    {
        "姓名": "杨薇",
        "OA账号": "yangwei202",
        "联系电话": "18602030964"
    },
    {
        "姓名": "夏隽依",
        "OA账号": "xiajy8",
        "联系电话": "18602030685"
    },
    {
        "姓名": "徐远钿",
        "OA账号": "xuyd",
        "联系电话": "18602039955"
    },
    {
        "姓名": "贾占一",
        "OA账号": "jiazy23",
        "联系电话": "18602030024"
    },
    {
        "姓名": "罗文东",
        "OA账号": "luowd5",
        "联系电话": "18689390866"
    },
    {
        "姓名": "平怀逸",
        "OA账号": "pinghy6",
        "联系电话": "18602030507"
    },
    {
        "姓名": "陈勋",
        "OA账号": "chenx116",
        "联系电话": "18602031753"
    },
    {
        "姓名": "朱友芬",
        "OA账号": "zhuyf22",
        "联系电话": "18602031670"
    },
    {
        "姓名": "李国方",
        "OA账号": "ligf95",
        "联系电话": "18689398939"
    },
    {
        "姓名": "李春华",
        "OA账号": "lich271",
        "联系电话": "18602030407"
    },
    {
        "姓名": "王巍",
        "OA账号": "wangwei599",
        "联系电话": "18602030189"
    },
    {
        "姓名": "邝伟辉",
        "OA账号": "kuangwh",
        "联系电话": "18602031448"
    },
    {
        "姓名": "温志坚",
        "OA账号": "wenzj12",
        "联系电话": "18602032854"
    },
    {
        "姓名": "黎美婵",
        "OA账号": "limc39",
        "联系电话": "18602033847"
    },
    {
        "姓名": "肖寰",
        "OA账号": "xiaoh53",
        "联系电话": "18602034110"
    },
    {
        "姓名": "齐宇锋",
        "OA账号": "yufengqi",
        "联系电话": "18602031812"
    },
    {
        "姓名": "于昊哲",
        "OA账号": "yuhz39",
        "联系电话": "15602860017"
    },
    {
        "姓名": "杨柠旭",
        "OA账号": "yangnx5",
        "联系电话": "18602031943"
    },
    {
        "姓名": "慕长行",
        "OA账号": "muzx3",
        "联系电话": "15602869971"
    },
    {
        "姓名": "李春材",
        "OA账号": "licc93",
        "联系电话": "18602030283"
    },
    {
        "姓名": "李广生",
        "OA账号": "ligs70",
        "联系电话": "15602860859"
    },
    {
        "姓名": "陈立英",
        "OA账号": "chenly51",
        "联系电话": "15602860018"
    },
    {
        "姓名": "赵维丽",
        "OA账号": "zhaowl36",
        "联系电话": "15602860097"
    },
    {
        "姓名": "陈勇成",
        "OA账号": "gd-chenyc73",
        "联系电话": "15602860701"
    },
    {
        "姓名": "彭龙",
        "OA账号": "pengl118",
        "联系电话": "15602862225"
    },
    {
        "姓名": "郭连娣",
        "OA账号": "guold9",
        "联系电话": "15602861171"
    },
    {
        "姓名": "覃汉机",
        "OA账号": "qinhj11",
        "联系电话": "15602861806"
    },
    {
        "姓名": "利小军",
        "OA账号": "lixj268",
        "联系电话": "15602869836"
    },
    {
        "姓名": "尼涵郁",
        "OA账号": "nihy3",
        "联系电话": "15602861227"
    },
    {
        "姓名": "李慧",
        "OA账号": "lih256",
        "联系电话": "15602861180"
    },
    {
        "姓名": "张春明",
        "OA账号": "gd-zhangcm",
        "联系电话": "15602866182"
    },
    {
        "姓名": "潘茂华",
        "OA账号": "panmh3",
        "联系电话": "15602860618"
    },
    {
        "姓名": "陈健冰",
        "OA账号": "jianbingchen",
        "联系电话": "15602860673"
    },
    {
        "姓名": "王贤标",
        "OA账号": "wangxb96",
        "联系电话": "15602862228"
    },
    {
        "姓名": "张向鹏",
        "OA账号": "zhangxp1",
        "联系电话": "15602869511"
    },
    {
        "姓名": "林彬彬",
        "OA账号": "linbb5",
        "联系电话": "15602860898"
    },
    {
        "姓名": "勾勒",
        "OA账号": "goule1",
        "联系电话": "18602030971"
    },
    {
        "姓名": "陈利婷",
        "OA账号": "gd-chenlt2",
        "联系电话": "15602860554"
    },
    {
        "姓名": "陈洋",
        "OA账号": "gd-cheny55",
        "联系电话": "15602862085"
    },
    {
        "姓名": "林龙斌",
        "OA账号": "gd-linlb7",
        "联系电话": "15602860681"
    },
    {
        "姓名": "张文忠",
        "OA账号": "gd-zhangwz",
        "联系电话": "15602860757"
    },
    {
        "姓名": "冯铃娟",
        "OA账号": "gd-fenglj",
        "联系电话": "15602860761"
    },
    {
        "姓名": "王东娟",
        "OA账号": "gd-wangdj3",
        "联系电话": "15602860371"
    },
    {
        "姓名": "洪鑫",
        "OA账号": "gd-hongx5",
        "联系电话": "15602867598"
    },
    {
        "姓名": "田宇",
        "OA账号": "gd-tianyu",
        "联系电话": "15602867750"
    },
    {
        "姓名": "张文",
        "OA账号": "gd-zhangw8",
        "联系电话": "15602865625"
    },
    {
        "姓名": "梁家铭",
        "OA账号": "gd-liangjm3",
        "联系电话": "15602869152"
    },
    {
        "姓名": "杨伟业",
        "OA账号": "yangweiye",
        "联系电话": "15602860913"
    },
    {
        "姓名": "李淑英",
        "OA账号": "gd-lisy11",
        "联系电话": "15602861750"
    },
    {
        "姓名": "李子良",
        "OA账号": "lizl182",
        "联系电话": "15602860523"
    },
    {
        "姓名": "何家健",
        "OA账号": "gd-hejj5",
        "联系电话": "15602869272"
    },
    {
        "姓名": "黄乾永",
        "OA账号": "gd-huangqy3",
        "联系电话": "15602867573"
    },
    {
        "姓名": "赵章广",
        "OA账号": "gd-zhaozg",
        "联系电话": "15602861290"
    },
    {
        "姓名": "张敏峰",
        "OA账号": "gd-zhangmf",
        "联系电话": "15602860189"
    }
]


const query = (loginName) => {
    var myHeaders = new Headers();
    myHeaders.append("Pragma", "no-cache");
    myHeaders.append("X-Requested-With", "XMLHttpRequest");
    myHeaders.append("Cookie", "JSESSIONID=11CE2569721C9BF0A41B24DE25B7F6ED");
    myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
    myHeaders.append("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

    var urlencoded = new URLSearchParams();
    urlencoded.append("loginName", loginName);
    urlencoded.append("page", "1");
    urlencoded.append("rows", "15");

    var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: urlencoded,
        redirect: 'follow'
    };

    return fetch("http://10.177.77.86:3000/QMManager/appugroup/userData.do?json=&groupId=130&math=0.7172581454378475", requestOptions)
        .then(response => response.json().then(res => res.rows.find(it => it.loginName = loginName)))
        .then(result => {
            console.log(result)
            if (result) {
                return result.userId
            }
            return null
        })
        .catch(error => {
            console.log('error', error);
            return null
        });
}
const add = (userId) => {
    var myHeaders = new Headers();
    myHeaders.append("Pragma", "no-cache");
    myHeaders.append("X-Requested-With", "XMLHttpRequest");
    myHeaders.append("Cookie", "JSESSIONID=11CE2569721C9BF0A41B24DE25B7F6ED");
    myHeaders.append("User-Agent", "Apifox/1.0.0 (https://apifox.com)");
    myHeaders.append("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");

    var urlencoded = new URLSearchParams();
    urlencoded.append("groupId", "130");
    urlencoded.append("userIds", userId + ",");

    var requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: urlencoded,
        redirect: 'follow'
    };

    return fetch("http://10.177.77.86:3000/QMManager/appugroup/binduser.do?math=0.5717302052889162", requestOptions)
        .then(response => response.text())
        .then(result => {
            return result
        })
        .catch(error => console.warn('error', error));
}

// dataList = dataList.slice(-3)
const main = async () => {

    while (dataList.length) {
        const item = dataList.pop()
        const userId = await query(item['OA账号'])
        if (userId) {
            const res = await add(userId)
            console.log(JSON.stringify(item), 'add结果', res)

        } else {
            console.warn(JSON.stringify(item), '查询失败')
        }
    }
}
main()